/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import com.openbrew.openbrewrf.views.YeastGensView;
import com.openbrew.openbrewrf.views.YeastView;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "YeastGens")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "YeastGens.findAll", query = "SELECT y FROM YeastGens y"),
    @NamedQuery(name = "YeastGens.findByYeastGenID", query = "SELECT y FROM YeastGens y WHERE y.yeastGenID = :yeastGenID"),
    @NamedQuery(name = "YeastGens.findByYGGeneration", query = "SELECT y FROM YeastGens y WHERE y.yGGeneration = :yGGeneration"),
    @NamedQuery(name = "YeastGens.findByYGCellCount", query = "SELECT y FROM YeastGens y WHERE y.yGCellCount = :yGCellCount"),
    @NamedQuery(name = "YeastGens.findByYGViability", query = "SELECT y FROM YeastGens y WHERE y.yGViability = :yGViability"),
    @NamedQuery(name = "YeastGens.findByYGDensity", query = "SELECT y FROM YeastGens y WHERE y.yGDensity = :yGDensity"),
    @NamedQuery(name = "YeastGens.findByYGVitality", query = "SELECT y FROM YeastGens y WHERE y.yGVitality = :yGVitality"),
    @NamedQuery(name = "YeastGens.findByYGNotes", query = "SELECT y FROM YeastGens y WHERE y.yGNotes = :yGNotes"),
    @NamedQuery(name = "YeastGens.findUnPitched", query = "SELECT y FROM YeastGens y WHERE y.yGPitched = 'false'")})
public class YeastGens implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "YeastGenID")
    private Integer yeastGenID;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YGGeneration")
    private int yGGeneration;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YGCellCount")
    private float yGCellCount;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YGViability")
    private float yGViability;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YGDensity")
    private float yGDensity;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YGVitality")
    private float yGVitality;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "YGNotes")
    private String yGNotes;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YGDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date yGDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YGPitched")
    private boolean yGPitched;
    @Basic(optional = false)
    @NotNull
    @Column(name = "volume")
    private float yGVolume;
    @JoinColumn(name = "YGPreviousYeastGen", referencedColumnName = "YeastGenID", nullable=true)
    @ManyToOne(optional = true)
    private YeastGensView yGPreviousYeastGen;
    @JoinColumn(name = "YGYeastID", referencedColumnName = "YID")
    @ManyToOne(optional = false)
    private YeastView yGYeastID;
    @JoinColumn(name = "YGBrinkID", referencedColumnName = "BrinkID")
    @ManyToOne(optional = false)
    private Brinks yGBrinkID;
    @OneToMany(mappedBy = "yeastGen")
    private Collection<PitchNotes> pitchNotesCollection;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YGOriginatingBrew")
    private int yGOriginatingBrew;
    @Basic(optional = false)
    @NotNull
    @Column(name = "YGBrew")
    private int yGBrew;
    
    public YeastGens() {
    }

    public YeastGens(Integer yeastGenID) {
        this.yeastGenID = yeastGenID;
    }

    public YeastGens(Integer yeastGenID, int yGGeneration, float yGCellCount, float yGViability, float yGDensity, float yGVitality, String yGNotes) {
        this.yeastGenID = yeastGenID;
        this.yGGeneration = yGGeneration;
        this.yGCellCount = yGCellCount;
        this.yGViability = yGViability;
        this.yGDensity = yGDensity;
        this.yGVitality = yGVitality;
        this.yGNotes = yGNotes;
    }

    public Integer getYeastGenID() {
        return yeastGenID;
    }

    public void setYeastGenID(Integer yeastGenID) {
        this.yeastGenID = yeastGenID;
    }

    public YeastView getYGYeastID() {
        return yGYeastID;
    }

    public void setYGYeastID(YeastView yGYeastID) {
        this.yGYeastID = yGYeastID;
    }

    public Brinks getYGBrinkID() {
        return yGBrinkID;
    }

    public void setYGBrinkID(Brinks yGBrinkID) {
        this.yGBrinkID = yGBrinkID;
    }

    public int getYGGeneration() {
        return yGGeneration;
    }

    public void setYGGeneration(int yGGeneration) {
        this.yGGeneration = yGGeneration;
    }

    public float getYGCellCount() {
        return yGCellCount;
    }

    public void setYGCellCount(float yGCellCount) {
        this.yGCellCount = yGCellCount;
    }

    public float getYGViability() {
        return yGViability;
    }

    public void setYGViability(float yGViability) {
        this.yGViability = yGViability;
    }

    public float getYGDensity() {
        return yGDensity;
    }

    public void setYGDensity(float yGDensity) {
        this.yGDensity = yGDensity;
    }

    public float getYGVitality() {
        return yGVitality;
    }

    public void setYGVitality(float yGVitality) {
        this.yGVitality = yGVitality;
    }

    public int getYGOriginatingBrew() {
        return yGOriginatingBrew;
    }

    public void setYGOriginatingBrew(int yGOriginatingBrew) {
        this.yGOriginatingBrew = yGOriginatingBrew;
    }

    public int getYGBrew() {
        return yGBrew;
    }

    public void setYGBrew(int yGBrew) {
        this.yGBrew = yGBrew;
    }

    public YeastGensView getYGPreviousYeastGen() {
        return yGPreviousYeastGen;
    }

    public void setYGPreviousYeastGen(YeastGensView yGPreviousYeastGen) {
        if(yGPreviousYeastGen.getYeastGenID()!=null){
            this.yGPreviousYeastGen = yGPreviousYeastGen;
        }
    }

    public String getYGNotes() {
        return yGNotes;
    }

    public void setYGNotes(String yGNotes) {
        this.yGNotes = yGNotes;
    }

    public Date getYGDate() {
        return yGDate;
    }

    public void setYGDate(Date bDate) {
        this.yGDate = bDate;
    }

    public boolean getYGPitchedFilter() {
        return yGPitched;
    }

    public void setYGPitchedFilter(boolean ganttFilter) {
        this.yGPitched = ganttFilter;
    }

    public float getyGVolume() {
        return yGVolume;
    }

    public void setyGVolume(float yGVolume) {
        this.yGVolume = yGVolume;
    }

    @XmlTransient
    public Collection<PitchNotes> getPitchNotesCollection() {
        return pitchNotesCollection;
    }

    public void setPitchNotesCollection(Collection<PitchNotes> pitchNotesCollection) {
        this.pitchNotesCollection = pitchNotesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (yeastGenID != null ? yeastGenID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof YeastGens)) {
            return false;
        }
        YeastGens other = (YeastGens) object;
        if ((this.yeastGenID == null && other.yeastGenID != null) || (this.yeastGenID != null && !this.yeastGenID.equals(other.yeastGenID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.YeastGens[ yeastGenID=" + yeastGenID + " ]";
    }
    
}
